#include "Output.h"

void OptGI(Object *pCursor)
  {
    int HP = pCursor->HP;
  }

void OptCursor(Object *pCursor)
  {
    int HP = pCursor->HP;
    if (HP <= 3)
      OptRedCursor(pCursor);
    else if (HP <= 6)
      OptYellowCursor(pCursor);
    else
      OptWhiteCursor(pCursor);
  }
void OptYellowCursor(Object *pCursor)
  {
    int X = pCursor->X, Y = pCursor->Y;
    IMAGE ImgYellowCursor;
    loadimage(&ImgYellowCursor, _T("Pic/Cursor/YellowCursor.png"));
    putimage(X, Y, &ImgYellowCursor);
  }
void OptRedCursor(Object *pCursor)
  {
    int X = pCursor->X, Y = pCursor->Y;
    IMAGE ImgRedCursor;
    loadimage(&ImgRedCursor, _T("Pic/Cursor/RedCursor.png"));
    putimage(X, Y, &ImgRedCursor);
  }
void OptWhiteCursor(Object *pCursor)
  {
    int X = pCursor->X, Y = pCursor->Y;
    IMAGE ImgWhiteCursor;
    loadimage(&ImgWhiteCursor, _T("Pic/Cursor/WhiteCursor.png"));
    putimage(X, Y, &ImgWhiteCursor);
  }

void OptDoorLight(int X, int Y)
  {
    IMAGE ImgDoorLight;
    loadimage(&ImgDoorLight, _T("Pic/Hint/DoorLight.png"));
    TransparentImage(NULL, X, Y, &ImgDoorLight);
  }
void OptKey(int X, int Y)
  {
    IMAGE ImgKey;
    loadimage(&ImgKey, _T("Pic/Hint/Key.png"));
    TransparentImage(NULL, X, Y, &ImgKey);
  }
void TransparentImage(IMAGE *dstimg, int x, int y, IMAGE *srcimg)
  {
  	HDC dstDC = GetImageHDC(dstimg);
  	HDC srcDC = GetImageHDC(srcimg);
  	int w = srcimg->getwidth();
  	int h = srcimg->getheight();
  	BLENDFUNCTION bf = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA};
  	AlphaBlend(dstDC, x, y, w, h, srcDC, 0, 0, w, h, bf);
  }

void OptCldPrsKey(int X, int Y)
  {
    IMAGE ImgCldPress;
    loadimage(&ImgCldPress, _T("Pic/Hint/CouldPress.png"));
    TransparentImage(NULL, X, Y, &ImgCldPress);
  }
void OptIntro(int Level)
  {
    time_t StartTime, EndTime;
    StartTime = time(NULL);
    int Still = 1;

    while (Still)
      {
        if (Level == 0)
          Exp0Intro();
        if (Level == 1)
          Exp1Intro();
        if (Level == 2)
          Exp2Intro();
        if (Level == 3)
          Exp3Intro();

        EndTime = time(NULL);
        if (difftime(EndTime, StartTime) >= 5)
          {
            OptCldPrsKey(56, 439);
            if (_kbhit())
              Still = 0;
          }
        else// the time to reading Intro
          {
            if (_kbhit())
              _getch();
          }
        FlushBatchDraw();
      }
  }
void Exp0Intro()
  {
    IMAGE Exp0IntroImg;
    loadimage(&Exp0IntroImg, _T("Pic/Intro/Level0.png"));
    putimage(0, 0, &Exp0IntroImg);
  }
void Exp1Intro()
  {
    IMAGE Exp1IntroImg;
    loadimage(&Exp1IntroImg, _T("Pic/Intro/Level1.png"));
    putimage(0, 0, &Exp1IntroImg);
  }
void Exp2Intro()
  {
    IMAGE Exp2IntroImg;
    loadimage(&Exp2IntroImg, _T("Pic/Intro/Level2.png"));
    putimage(0, 0, &Exp2IntroImg);
  }
void Exp3Intro()
  {
    IMAGE Exp3IntroImg;
    loadimage(&Exp3IntroImg, _T("Pic/Intro/Level3.png"));
    putimage(0, 0, &Exp3IntroImg);
  }
